package com.nsfocus.mode;

/**
 * @File: SingleDemo.java
 * @User: Liangkangkang
 * @Date: 17-4-24
 * @Time: 下午5:23
 * @Mail: liangkangkang@yahoo.com
 * @Desc:　单例降低耦合
 * @Version:
 */

import java.io.InputStream;

/**
 * 单例模式：懒汉式
 */
class SingleLazy {
    private static  SingleLazy instance;
    public static SingleLazy getInstance(){
        if (instance == null){
            instance = new SingleLazy();
        }
        return instance;
    }
    private SingleLazy(){
    }
}

/**
 * 单例模式：饿汉式
 */
class SingleHungry {
    private static  SingleHungry instance = new SingleHungry();
    public static SingleHungry getInstance(){
        return  instance;
    }
    private SingleHungry(){
    }

}
public class SingleDemo{

}
